<template>
  <el-form ref="form" :model="dataForm" label-width="180px">
    <el-form-item label="单次分享积分：">
      <el-col :span="2">
        <el-input v-model="dataForm.shareIntegral"></el-input>
      </el-col>
    </el-form-item>
    <el-form-item label="单日最大分享积分：">
      <el-col :span="2">
        <el-input v-model="dataForm.maxShareIntegral"></el-input>
      </el-col>
    </el-form-item>
    <el-form-item label="单词报名分享积分：">
      <el-col :span="2">
        <el-input v-model="dataForm.signUpIntegral"></el-input>
      </el-col>
    </el-form-item>
    <el-form-item label="单日最大报名积分：">
      <el-col :span="2">
        <el-input v-model="dataForm.maxSignUpIntegral"></el-input>
      </el-col>
    </el-form-item>
    <el-form-item label="新员工入职积分：">
      <el-col :span="2">
        <el-input v-model="dataForm.newWorkerIntegral"></el-input>
      </el-col>
    </el-form-item>
    <el-form-item label="每日在职员工固定积分：">
      <el-col :span="2">
        <el-input v-model="dataForm.workerIntegral"></el-input>
      </el-col>
    </el-form-item>
    <el-form-item label="关注微信公众号获取积分：">
      <el-col :span="2">
        <el-input v-model="dataForm.wxPublicIntegral"></el-input>
      </el-col>
    </el-form-item>

    <el-form-item>
      <el-button type="primary" @click="onSubmit">提交</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
export default {
  name: 'index',
  data () {
    return {
      dataForm: {
        id: '',
        shareIntegral: '',
        maxShareIntegral: '',
        signUpIntegral: '',
        maxSignUpIntegral: '',
        newWorkerIntegral: '',
        workerIntegral: '',
        wxPublicIntegral: ''
      }
    }
  },
  mounted(){
    this.getData()
  },
  methods: {
    getData () {
      this.dataListLoading = true
      this.$http({
        url: this.$http.adornUrl('/v1/integral/rule'),
        method: 'get',
        params: this.$http.adornParams()
      }).then(({data}) => {
        console.log(data)
        this.dataForm = data.data
      })
    },
    onSubmit () {
      console.log(this.dataForm)
      this.$confirm(`确定进行设置积分操作?`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          this.$http({
            url: this.$http.adornUrl(`/v1/integral/rule/update`),
            method: 'post',
            data: this.$http.adornData(this.dataForm)
          }).then(({data}) => {
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {
                this.getData()
              }
            })
          })
        })
        .catch(() => {
        })
    }
  }
}
</script>

<style scoped>

</style>
